package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.FriendPraise;
import cn.wolfcode.trip.base.query.FriendPraiseQueryObject;
import cn.wolfcode.trip.base.service.IFriendPraiseService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonRawValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/friendPraise")
public class FriendPraiseController {
    @Autowired
    private IFriendPraiseService friendPraiseService;

    /**
     * 新增一条点赞记录
     * @param friendPraise
     * @return
     */
    @PostMapping
    public JSONResult save(FriendPraise friendPraise){
        friendPraiseService.save(friendPraise);
        return new JSONResult();
    }

    /**
     * 删除一条点赞记录
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public JSONResult delete(@PathVariable Long id){
        friendPraiseService.delete(id);
        return new JSONResult();
    }

    /**
     * 进行点赞取消操作
     * @param qo
     * @return
     */
    @GetMapping(value = "/{dynamicId}",produces = "application/json; charset=utf-8")
    public String getPraise(FriendPraiseQueryObject qo, HttpServletResponse response){
        return friendPraiseService.operatingPraise(qo);
    }
}